if __name__ == '__main__':
    # 定义字符串
    str1 = 'hello world!!!'
    # 字符串的常用操作
    # 获取字符串的长度
    print(len(str1))
    # 字符串的索引概念
    for i in range(0,len(str1)):
        print(str1[i])
    for c in str1:
        print(c)
    # 切片操作 str1[起始索引：结束索引：步长]
    str2 = str1[1:3]
    print(str2)
    str3 =str1[:4]
    print(str3)
    # 字符串反转
    str5 = str1[::-1]
    print(str5)
    str6 = str1 [5:3:-1]
    print(str6)

    # 字符串的分割操作
    strlist = str.split(' ')
    print(strlist)
    # 替换操作
    str7 = str1.replace("!","?")
    print(str7)
    # 统计一个字符串中字符出现的个数
    print(str1.count('l'))
    print(str1.count('o'))
    print(str1.count('llo'))